<?php
	global $ubi;
	
	if ($getVars['userid'] != $_SESSION['userid']) {
?>
<div class="organicContent">
	<div class="inside">               
		<ul class="profile">
    		<li class="sendmess">
        		<a href="#" id="lnkSendMess">Gửi tin nhắn</a>
        	</li>
            <?php 
            	if ($isFriend == 0) {
			?>
            <li class="makefriends">
            	<a href="index.php?add&type=friend&userid=<?php echo $user->getUserID();?>">Kết bạn</a>
            </li>
            <?php
            	} else if ($isFriend == 2) {
            ?>
            <li class="makefriends">Chờ xác nhận kết bạn</li>
            <?php 
            	} else if ($isFriend == 3) {
            ?>
            <li class="makefriends">
            	<a href="index.php?add&type=friend&userid=<?php echo $user->getUserID();?>">Đang chờ bạn xác nhận là bạn</a>
            </li>
            <?php 
            	} else if ($isFriend == 1) {
            ?>
            <li class="delete"><a class="cursor" onclick="">Xóa khỏi danh sách</a></li>
            <?php
            	} 
            ?>
            <li class="alert"><a href="#">Báo cáo vi phạm</a></li>
		</ul>
	</div>
</div>
            
<?php
	}
	if ($_SESSION['userid'] == $getVars['userid']) {		
?>     
<div class="organicContent">
	<div class="inside">               
    	<ul class="profile">
    		<li class="update"><a href="index.php?update&type=profile">Cập nhật profile</a></li>
        	<li class="rss"><a href="#">Thông tin mới từ bạn bè</a></li>
            <li class="mess">
            	<a href="index.php?message&type=newestMessages">
            		Những tin nhắn 
            		<b>
            			<?php
            				if ($nUnreadMessage > 0) { 
            					echo $nUnreadMessage . ' tin';
            				}
            			?>
            		</b>
            	</a>
            </li>                        
      	</ul>
    </div>
</div>
<?php
	}
?>

<div id="dlgSendMessage" title="Gửi tin nhắn">
	<form id="frmSendMess" name="frmSendMess">
		Tiêu đề<br />
		<input type="text" name="title" size="41" />
		Nội dung<br />		
		<textarea rows="4" cols="41" name="mess"></textarea>
		<br /><br />
		<input type="submit" value="Gửi" />
	</form>
</div>
            
<script language="javascript">
	$('.organicContent').corner('5px');
	
	$('#dlgSendMessage').dialog({autoOpen: false, width:'400px'});
	
	$('#frmSendMess').submit(function() {
		var url = "index.php?send&type=message";
		var mess = $('#frmSendMess textarea[name=mess]').val();
		var receiverId = <?php echo $getVars['userid']?>;
		var title = $('#frmSendMess input[name=title]').val();		
		
		if (receiverId && $.trim(mess) != '') {
			$.post(url, {receiverId:receiverId, mess:mess, title:title}, function(data){
				if (data) {
					$('#frmSendMess textarea[name=mess]').val('');
					$('#frmSendMess input[name=title]').val('');
					$('#dlgSendMessage').dialog('close');			
					alert('Gửi tin nhắn thành công');
				} 
				return false;
			});
		}
		return false;
	});
	
	$('#lnkSendMess').click(function() {
		$('#dlgSendMessage').dialog('open');							
	});
</script>